package com.music.mapper;

import com.music.pojo.Activity;
import com.music.pojo.ActivityExample;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

public interface ActivityMapper {
    @SelectProvider(type=ActivitySqlProvider.class, method="countByExample")
    long countByExample(ActivityExample example);

    @DeleteProvider(type=ActivitySqlProvider.class, method="deleteByExample")
    int deleteByExample(ActivityExample example);

    @Delete({
        "delete from activity",
        "where aid = #{aid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer aid);

    @Insert({
        "insert into activity (aid, text, ",
        "uid)",
        "values (#{aid,jdbcType=INTEGER}, #{text,jdbcType=VARCHAR}, ",
        "#{uid,jdbcType=INTEGER})"
    })
    int insert(Activity row);

    @InsertProvider(type=ActivitySqlProvider.class, method="insertSelective")
    int insertSelective(Activity row);

    @SelectProvider(type=ActivitySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="aid", property="aid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="text", property="text", jdbcType=JdbcType.VARCHAR),
        @Result(column="uid", property="uid", jdbcType=JdbcType.INTEGER)
    })
    List<Activity> selectByExample(ActivityExample example);

    @Select({
        "select",
        "aid, text, uid",
        "from activity",
        "where aid = #{aid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="aid", property="aid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="text", property="text", jdbcType=JdbcType.VARCHAR),
        @Result(column="uid", property="uid", jdbcType=JdbcType.INTEGER)
    })
    Activity selectByPrimaryKey(Integer aid);

    @UpdateProvider(type=ActivitySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("row") Activity row, @Param("example") ActivityExample example);

    @UpdateProvider(type=ActivitySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("row") Activity row, @Param("example") ActivityExample example);

    @UpdateProvider(type=ActivitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Activity row);

    @Update({
        "update activity",
        "set text = #{text,jdbcType=VARCHAR},",
          "uid = #{uid,jdbcType=INTEGER}",
        "where aid = #{aid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Activity row);


    @Select("select * from activity")
    @Results(id = "auMap",value = {
            @Result(id = true,column = "aid",property = "aid"),
            @Result(column = "text",property = "text"),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "uid",property = "userInfo",
                    one = @One(select="com.music.mapper.UserInfoMapper.findByUid")),
    })
    List<Activity> findAllWithUser();
}